home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / SICL / data1.cab / sicl32 / c / samples / misc / vmeintr.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  1.2 KB  |  51 lines

  1. /* vmeintr.c
  2.    This example uses SICL to cause a VME interrupt from an
  3.    Agilent E1361 register-based relay card at logical address 136. */
  4. #include <stdio.h>
  5. #include <sicl.h>
  6.  
  7. static void vmeint (INST, unsigned short);
  8. static void int_setup (INST, unsigned long);
  9. static void int_hndlr (INST, long, long);
  10. int intr = 0;
  11.  
  12. void main() {
  13.   INST id_intf1;
  14.   unsigned long mask = 1;
  15.  
  16.   ionerror (I_ERROR_EXIT);
  17.   iintroff ();
  18.   id_intf1 = iopen ("vxi,136");
  19.   int_setup (id_intf1, mask);
  20.   vmeint (id_intf1, 136);
  21.  
  22.   /* wait for SRQ or interrupt condition */
  23.   iwaithdlr (0);
  24.  
  25.   iintron ();
  26.   iclose (id_intf1);
  27. }
  28.  
  29. static void int_setup(INST id, unsigned long mask) {
  30.   ionintr(id, int_hndlr);
  31.   isetintr(id, I_INTR_VXI_SIGNAL, mask);
  32. }
  33.  
  34. static void vmeint (INST id, unsigned short laddr) {
  35.   int reg;
  36.   unsigned long a16map = 0;
  37.  
  38.   reg = 8;
  39.   a16map = imapx (id, I_MAP_A16, 0, 1);
  40.  
  41.   /* Cause relay card to interrupt: */
  42.   ipokex16(id, a16map, 0xc000 + (laddr * 64) + reg, 0x0);
  43.  
  44.   iunmapx(id, a16map, I_MAP_A16, 0, 1);
  45. }
  46.  
  47. static void int_hndlr (INST id, long reason, long sec) {
  48.   printf ("VME interrupt: reason: 0x%lx, sec: 0x%lx\n", reason, sec);
  49.   intr = 1;
  50. }
  51.